﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Oracle.DataAccess;
using System.Data.OracleClient;
using EntitiesLayer.Entities;
using System.Data;

namespace DataLayer.DAO
{
    public class SeguimientoqrDerivacionDAO
    {
        private Connection.Connection cn;
        private OracleConnection objCn;
        public SeguimientoqrDerivacionDAO()
        {
            cn = new Connection.Connection();
            objCn = cn.Conecta();
        }

        public int insertSeguimientoQrDerivar(QuejaReclamo objQyR)
        {
            int resultado = 0;
            try
            {
                OracleCommand cmd = new OracleCommand("INSERT_SEGUIMIENTOQYR", objCn);
                objCn.Open();
                cmd.Connection = objCn;
                cmd.CommandTimeout = 60;
                cmd.CommandType = CommandType.StoredProcedure;                
                cmd.Parameters.Add(new OracleParameter("Rrec_Cod_Rec", OracleType.NVarChar, 30, ParameterDirection.Input, false, 10, 0, null, DataRowVersion.Current, objQyR.VREC_COD_REC));                
                cmd.Parameters.Add(new OracleParameter("Rrec_Cod_Caracteristica_Resp", OracleType.NVarChar, 20, ParameterDirection.Input, false, 10, 0, null, DataRowVersion.Current, objQyR.VREC_COD_CARACTERISTICA_RESP));
                cmd.Parameters.Add(new OracleParameter("Rrec_Sustento_Respuesta", OracleType.NVarChar, 50, ParameterDirection.Input, false, 10, 0, null, DataRowVersion.Current, objQyR.VREC_SUSTENTO_RESPUESTA));
                resultado = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                objCn.Dispose();
            }
            finally
            {
                if (objCn != null)
                {
                    objCn.Close();
                }
            }
            return resultado;
        }

        public int insertQrDerivar(QuejaReclamo objQyR)
        {
            int resultado = 0;
            try
            {
                OracleCommand cmd = new OracleCommand("INSERTSEGQR_DERIVACION", objCn);
                objCn.Open();
                cmd.Connection = objCn;
                cmd.CommandTimeout = 60;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new OracleParameter("Rrec_Cod_Rec", OracleType.NVarChar, 30, ParameterDirection.Input, false, 10, 0, null, DataRowVersion.Current, objQyR.VREC_COD_REC));
                cmd.Parameters.Add(new OracleParameter("Rsire_Cod_Resultado", OracleType.NVarChar, 10, ParameterDirection.Input, false, 10, 0, null, DataRowVersion.Current, objQyR.Vsire_Cod_Resultado));
                cmd.Parameters.Add(new OracleParameter("Rare_Cod_Area", OracleType.NVarChar, 10, ParameterDirection.Input, false, 10, 0, null, DataRowVersion.Current, objQyR.VARE_COD_AREA));
                cmd.Parameters.Add(new OracleParameter("Rsqrd_Observacion", OracleType.NVarChar, 10, ParameterDirection.Input, false, 10, 0, null, DataRowVersion.Current, objQyR.Vsqrd_Observacion));
                cmd.Parameters.Add(new OracleParameter("Rsqrd_Fecha_Derivacion", OracleType.NVarChar, 20, ParameterDirection.Input, false, 10, 0, null, DataRowVersion.Current, objQyR.Dsqrd_Fecha_Derivacion));
                cmd.Parameters.Add(new OracleParameter("Rsqrd_Usuario_Respon", OracleType.NVarChar, 50, ParameterDirection.Input, false, 10, 0, null, DataRowVersion.Current, objQyR.Vsqrd_Usuario_Respon));
                resultado = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                objCn.Dispose();
            }
            finally
            {
                if (objCn != null)
                {
                    objCn.Close();
                }
            }
            return resultado;
        }

    }
}
